package com.byxy.action;



import javax.annotation.Resource;

import org.apache.struts2.ServletActionContext;

import com.byxy.entity.User;
import com.byxy.service.UserService;
import com.opensymphony.xwork2.ActionSupport;


public class UserRegistAction extends ActionSupport {
	public String regist() {

		return "regist";
	}

	private String username;

	private String password;

	private String name;

	private String email;

	private String phone;

	private String addr;

	@Resource
	private UserService userService;
	private String checkcode;
	
	public String doregist() {
		String checkcode1=(String) ServletActionContext.getRequest().getSession().getAttribute("checkcode");
		if (!(checkcode.equalsIgnoreCase(checkcode1))) {
			this.addActionError("验证码输入错误");
			return "errorcheckcode";
		}
		userService.add(new User(username, password, name, email, phone, addr));
		return SUCCESS;
	}
	

	public String getUsername() {
		return username;
	}

	public void setUsername(String username) {
		this.username = username;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getEmail() {
		return email;
	}

	public void setEmail(String email) {
		this.email = email;
	}

	public String getPhone() {
		return phone;
	}

	public void setPhone(String phone) {
		this.phone = phone;
	}

	public String getAddr() {
		return addr;
	}

	public void setAddr(String addr) {
		this.addr = addr;
	}

	public String getCheckcode() {
		return checkcode;
	}


	public void setCheckcode(String checkcode) {
		this.checkcode = checkcode;
	}


}
